import { Component, OnInit, ViewChild, Injector, AfterViewInit, ViewEncapsulation, ElementRef } from '@angular/core';
import { appModuleAnimation } from '@shared/animations/routerTransition';
import { SelectItem } from 'primeng/api';
import { AppComponentBase } from '@shared/common/app-component-base';
import { Table } from 'primeng/table';
import { Paginator, LazyLoadEvent, FileUpload } from 'primeng/primeng';
import { TechFileServiceProxy, FileRecordServiceProxy, TechFileOutServiceProxy, BorrowTechFileDto, TechFileState, AtionState, ComboboxItemDto, TechFileInfoServiceProxy, TechFileBaseInputDto, PagedResultDtoOfTechFileListDto } from '@shared/service-proxies/service-proxies';
import * as moment from 'moment';
import { BsDatepickerViewMode } from 'ngx-bootstrap/datepicker/models';
import { BsDatepickerConfig, BsDaterangepickerConfig } from 'ngx-bootstrap';
import { finalize } from 'rxjs/operators';
import * as G2 from '@antv/g2';
import { PrimengTableHelper } from '@shared/helpers/PrimengTableHelper';
import { AppConsts } from '@shared/AppConsts';
import { HttpClient } from '@angular/common/http';
import { Action } from 'rxjs/internal/scheduler/Action';
import { ViewCompiler } from '@angular/compiler';
import { SelectLocationComponent } from '@app/shared/common/select-location/select-location.component';
import { PutReceiveTechfileModalComponent } from './putreceive-techfile-modal.component';
import { forEach } from 'lodash';
import { FileDownloadService } from '@shared/utils/file-download.service';
@Component({
  selector: 'app-techfile',
  templateUrl: './techfile.component.html',
  styleUrls: ['./techfile.component.less'],
  encapsulation: ViewEncapsulation.None,
  styles: [`
  :host ::ng-deep .ui-button {
      margin: .5em .5em .5em 0;
      width: 140px;
  }
  @media screen and (max-width: 40em) {
      :host ::ng-deep .ui-dialog {
          width: 75vw !important;
      }
  }
`],
  animations: [appModuleAnimation()]
})
export class TechfileComponent extends AppComponentBase implements OnInit {


  @ViewChild('dataTable') dataTable: Table;
  @ViewChild('paginatorNormal') paginatorNormal: Paginator;
  @ViewChild('paginatorSpecial') paginatorSpecial: Paginator;
  @ViewChild('paginatorReturning') paginatorReturning: Paginator;
  @ViewChild('paginatorOnloan') paginatorOnloan: Paginator;
  @ViewChild('paginatorTobe') paginatorTobe: Paginator;
  @ViewChild('paginatorBoorwte') paginatorBoorwte: Paginator; 
  @ViewChild('paginatorVoided') paginatorVoided: Paginator;

  @ViewChild('dataTableReturningProductions') dataTableReturningProductions: Table;
  @ViewChild('dataTableOnloanProductions') dataTableOnloanProductions: Table;
  @ViewChild('dataTableTobeProductions') dataTableTobeProductions: Table;
  @ViewChild('dataTableBoorwteProductions') dataTableBoorwteProductions: Table;
  @ViewChild('dataTableNormalProductions') dataTableNormalProductions: Table;
  @ViewChild('dataTableSpecialProductions') dataTableSpecialProductions: Table;
  @ViewChild('dataTableFileRecordProductions') dataTableFileRecordlProductions: Table; 
  @ViewChild('dataTableFileVoidedProductions') dataTableFileVoidedProductions: Table;
  @ViewChild('ExcelFileUpload') excelFileUpload: FileUpload;
  @ViewChild('sele') sele: SelectLocationComponent;
  advancedFiltersAreShown: Boolean = false;
  uploadUrl: string;

  primengTableHelperNormalProductions = new PrimengTableHelper();
  primengTableHelperSpecialProductions = new PrimengTableHelper();
  primengTableFileRecordProductions = new PrimengTableHelper();
  primengTableHelperReturningProductions = new PrimengTableHelper();
  primengTableHelperOnloanProductions = new PrimengTableHelper();
  primengTableFileTobeProductions = new PrimengTableHelper();
  primengTableFileBoorwteProductions = new PrimengTableHelper();
 
  primengTableFileVoidedProductions = new PrimengTableHelper();

  filterTaskNo: string = '';
  filterName: string = '';
  filterPicNo: string = '';
  filterModel: string = '';
  filterPart: string = '';
  filterText: string = '';
  displayBasic: boolean;
  positionId = 0;
  selectedids = new Array<string>();
  selectedProducts: any[];
  selectedProductsgh: any[];
  selectedProductsjc: any[];
  selectedProductsupdate: any[]; 
  selectedProductsvoided: any[];
  stages: Array<ComboboxItemDto> = new Array<ComboboxItemDto>();
  securitys: Array<ComboboxItemDto> = new Array<ComboboxItemDto>();
  filetypes: Array<ComboboxItemDto> = new Array<ComboboxItemDto>();

  startFilterDate: Date;
  endFilterDate: Date;


  @ViewChild('techFileInfoTypeCombobox') techFileInfoTypeCombobox: ElementRef;
  @ViewChild('securityTypeCombobox') securityTypeCombobox: ElementRef;
  @ViewChild('stageTypeCombobox') stageTypeCombobox: ElementRef;
  @ViewChild('putAllIntoModal') putAllIntoModal: PutReceiveTechfileModalComponent;

  stage = 0;
  security = 0;
  filetype = 0;
  emptyText=" ";

  onlyHaveNotRoutes = false;
  isTemporaryLaborHour = false;
  boor = new BorrowTechFileDto();

  tabIndex = 0;
  ExpireSelect: SelectItem[];
  borrowNameFilter = ''
  isExpireFilter = ''

  constructor(
    injector: Injector,
    private _techFileIntoServiceProxy: TechFileServiceProxy,
    private _techFileOutServiceProxy: TechFileOutServiceProxy,
    private _fileRecordServiceProxy: FileRecordServiceProxy,
    private _techfileServiceProxy: TechFileInfoServiceProxy,
    private _httpClient: HttpClient,
    private _fileDownloadService: FileDownloadService,
  ) {
    super(injector);
    this.uploadUrl = AppConsts.remoteServiceBaseUrl + '/LaborHourLib/ImportLibForLaborHourExcel';

  }

  tabList: any = [
    {
      IncludeState: '',
      ExceptState: '作废,待接收',
      Ele: () => {
        return this.primengTableHelperNormalProductions
      },
      getPaginator: () => {
        return this.paginatorNormal
      },
      getSorting: () => {
        return this.primengTableHelperNormalProductions.getSorting(this.dataTableNormalProductions)
      },
      getMaxResultCount: (event) => {
        return this.primengTableHelperNormalProductions.getMaxResultCount(this.paginatorNormal, event)
      },
      getSkipCount: (event) => {
        return this.primengTableHelperNormalProductions.getSkipCount(this.paginatorNormal, event)
      }
    },
    {
      IncludeState: '待接收',
      ExceptState: '',
      Ele: () => {
        return this.primengTableHelperSpecialProductions
      },
      getPaginator: () => {
        return this.paginatorSpecial
      },
      getSorting: () => {
        return this.primengTableHelperSpecialProductions.getSorting(this.dataTableSpecialProductions)
      },
      getMaxResultCount: (event) => {
        return this.primengTableHelperSpecialProductions.getMaxResultCount(this.paginatorSpecial, event)
      },
      getSkipCount: (event) => {
        return this.primengTableHelperSpecialProductions.getSkipCount(this.paginatorSpecial, event)
      }
    },
    {
      IncludeState: '待归还,待更新',
      ExceptState: '',
      Ele: () => {
        return this.primengTableFileTobeProductions
      },
      getPaginator: () => {
        return this.paginatorTobe
      },
      getSorting: () => {
        return this.primengTableFileTobeProductions.getSorting(this.dataTableTobeProductions)
      },
      getMaxResultCount: (event) => {
        return this.primengTableFileTobeProductions.getMaxResultCount(this.paginatorTobe, event)
      },
      getSkipCount: (event) => {
        return this.primengTableFileTobeProductions.getSkipCount(this.paginatorTobe, event)
      }
    },
    {
      IncludeState: '归还中',
      ExceptState: '',
      Ele: () => {
        return this.primengTableHelperReturningProductions
      },
      getPaginator: () => {
        return this.paginatorReturning
      },
      getSorting: () => {
        return this.primengTableHelperReturningProductions.getSorting(this.dataTableReturningProductions)
      },
      getMaxResultCount: (event) => {
        return this.primengTableHelperReturningProductions.getMaxResultCount(this.paginatorReturning, event)
      },
      getSkipCount: (event) => {
        return this.primengTableHelperReturningProductions.getSkipCount(this.paginatorReturning, event)
      }
    },
    {
      IncludeState: '借出中',
      ExceptState: '',
      Ele: () => {
        return this.primengTableHelperOnloanProductions
      },
      getPaginator: () => {
        return this.paginatorOnloan
      },
      getSorting: () => {
        return this.primengTableHelperOnloanProductions.getSorting(this.dataTableOnloanProductions)
      },
      getMaxResultCount: (event) => {
        return this.primengTableHelperOnloanProductions.getMaxResultCount(this.paginatorOnloan, event)
      },
      getSkipCount: (event) => {
        return this.primengTableHelperOnloanProductions.getSkipCount(this.paginatorOnloan, event)
      }
    },
    {
      IncludeState: '借出',
      ExceptState: '',
      Ele: () => {
        return this.primengTableFileBoorwteProductions
      },
      getPaginator: () => {
        return this.paginatorBoorwte
      },
      getSorting: () => {
        return this.primengTableFileBoorwteProductions.getSorting(this.dataTableBoorwteProductions)
      },
      getMaxResultCount: (event) => {
        return this.primengTableFileBoorwteProductions.getMaxResultCount(this.paginatorBoorwte, event)
      },
      getSkipCount: (event) => {
        return this.primengTableFileBoorwteProductions.getSkipCount(this.paginatorBoorwte, event)
      }
    }, 
    {
      IncludeState: '作废',
      ExceptState: '',
      Ele: () => {
        return this.primengTableFileVoidedProductions
      },
      getPaginator: () => {
        return this.paginatorVoided
      },
      getSorting: () => {
        return this.primengTableFileVoidedProductions.getSorting(this.dataTableFileVoidedProductions)
      },
      getMaxResultCount: (event) => {
        return this.primengTableFileVoidedProductions.getMaxResultCount(this.paginatorVoided, event)
      },
      getSkipCount: (event) => {
        return this.primengTableFileVoidedProductions.getSkipCount(this.paginatorVoided, event)
      }
    }
  ]
  tabsMaxCount: number[] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

  onSelect(index) {
    this.tabIndex = index;
    this.getTabsMaxCount();
  }
  ngOnInit(): void {
    this.ExpireSelect = [
      {
        label: '是',
        value: '是'
      },
      {
        label: '否',
        value: '否'
      }
    ]
    this.getstage();
    this.getsecurity();
    this.getfiletype();
    this.getTabsMaxCount();
  }
  //借出是否过期筛选
  BorrowExpireChange(filter) {
    this.isExpireFilter = filter
    this.getTabsProduction()
  }
  //借出人筛选
  BorrowNameFilter(filter) {
    this.borrowNameFilter = filter
    this.getTabsProduction()
  }
  getTabsMaxCount() {
    this._techFileIntoServiceProxy.getTabsMaxCount(this.sele.areaId,
      this.sele.shelfId,
      this.sele.location,
      this.filetype == 0 ? undefined : this.filetype,
      this.stage == 0 ? undefined : this.stage,
      this.security == 0 ? undefined : this.security,
      this.startFilterDate ? moment(this.startFilterDate) : null,
      this.endFilterDate ? moment(this.endFilterDate) : null,
      '',
      '',
      this.filterText,
      '',
      1,
      1).subscribe((result) => {
        this.tabsMaxCount = result;
      })
  }
  getTabsProduction(tabIndex?: number, event?: LazyLoadEvent) {
    if (!tabIndex) {
      tabIndex = this.tabIndex
    }
    setTimeout(async () => {
      this.tabList[tabIndex].Ele().showLoadingIndicator();
      if (this.tabList[tabIndex].Ele().shouldResetPaging(event)) {
        this.tabList[tabIndex].getPaginator().changePage(0);
        return;
      }
      this.tabList[tabIndex].Ele().showLoadingIndicator();
      let result;
      if (tabIndex == 5) {
        result = await this.getProductionOut(
          this.tabList[tabIndex].getSorting(),
          this.tabList[tabIndex].getMaxResultCount(event),
          this.tabList[tabIndex].getSkipCount(event),
          this.tabList[tabIndex].IncludeState,
          this.tabList[tabIndex].ExceptState
        )
        this.tabsMaxCount[this.tabIndex] = result.totalCount;
      } else {
        result = await this.getProduction(
          this.tabList[tabIndex].getSorting(),
          this.tabList[tabIndex].getMaxResultCount(event),
          this.tabList[tabIndex].getSkipCount(event),
          this.tabList[tabIndex].IncludeState,
          this.tabList[tabIndex].ExceptState
        )
      }
      this.tabList[tabIndex].Ele().totalRecordsCount = result.totalCount;
      this.tabList[tabIndex].Ele().records = result.items;
      console.log(result.items)
      this.tabList[tabIndex].Ele().hideLoadingIndicator();
    }, 0);
  }
  getFileRecord(id: string, event?: LazyLoadEvent) {

    this.primengTableFileRecordProductions.showLoadingIndicator();
    this._fileRecordServiceProxy.getFileRecord(
      id
    )
      .subscribe((result) => {
        this.primengTableFileRecordProductions.records = result;
      });
  }
  getstage() {
    this._techfileServiceProxy.getComboboxItemForStageType().subscribe(result => {
      this.stages = result;
      setTimeout(() => {

        $(this.stageTypeCombobox.nativeElement).selectpicker('refresh');

      });
    });
  }
  getsecurity() {
    this._techfileServiceProxy.getComboboxItemForSecurityType().subscribe(result => {
      this.securitys = result;
      setTimeout(() => {


        $(this.securityTypeCombobox.nativeElement).selectpicker('refresh');
      });
    });
  }
  getfiletype() {
    this._techfileServiceProxy.getComboboxItemForTechFileInfoType().subscribe(result => {
      this.filetypes = result;
      setTimeout(() => {

        $(this.techFileInfoTypeCombobox.nativeElement).selectpicker('refresh');

      });
    });
  }
  exportToExcel() {
    setTimeout(() => {
      if (this.tabIndex == 5) {
        this._techFileIntoServiceProxy.getTechFileBorrowToExcel(
          this.borrowNameFilter,
          this.isExpireFilter,
          this.sele.areaId,
          this.sele.shelfId,
          this.sele.location,
          this.filetype == 0 ? undefined : this.filetype,
          this.stage == 0 ? undefined : this.stage,
          this.security == 0 ? undefined : this.security,
          this.startFilterDate ? moment(this.startFilterDate) : null,
          this.endFilterDate ? moment(this.endFilterDate) : null,
          this.tabList[this.tabIndex].IncludeState,
          this.tabList[this.tabIndex].ExceptState,
          this.filterText,
          this.tabList[this.tabIndex].getSorting(),
          1,
          1
        )
          .subscribe(result => {
            this._fileDownloadService.downloadTempFile(result);
          });
      } else {
        this._techFileIntoServiceProxy.getTechFileToExcel(
          this.sele.areaId,
          this.sele.shelfId,
          this.sele.location,
          this.filetype == 0 ? undefined : this.filetype,
          this.stage == 0 ? undefined : this.stage,
          this.security == 0 ? undefined : this.security,
          this.startFilterDate ? moment(this.startFilterDate) : null,
          this.endFilterDate ? moment(this.endFilterDate) : null,
          this.tabList[this.tabIndex].IncludeState,
          this.tabList[this.tabIndex].ExceptState,
          this.filterText,
          this.tabList[this.tabIndex].getSorting(),
          1,
          1
        )
          .subscribe(result => {
            this._fileDownloadService.downloadTempFile(result);
          });
      }
    }, 0);
  }
  getProduction(sorting: string, maxResultCount: number, skipCount: number, includeState: string, exceptState: string) {
    return new Promise<PagedResultDtoOfTechFileListDto>((reject, resolve) => {
      this._techFileIntoServiceProxy.getTechFile(
        this.sele.areaId,
        this.sele.shelfId,
        this.sele.location,
        this.filetype == 0 ? undefined : this.filetype,
        this.stage == 0 ? undefined : this.stage,
        this.security == 0 ? undefined : this.security,
        this.startFilterDate ? moment(this.startFilterDate) : null,
        this.endFilterDate ? moment(this.endFilterDate) : null,
        includeState,
        exceptState,
        this.filterText,
        sorting,
        maxResultCount,
        skipCount
      )
        .subscribe((result) => {
          reject(result);
        });
    })
  }
  getProductionOut(sorting: string, maxResultCount: number, skipCount: number, includeState: string, exceptState: string) {
    return new Promise<PagedResultDtoOfTechFileListDto>((reject, resolve) => {
      this._techFileIntoServiceProxy.getTechFileOut(
        this.borrowNameFilter,
        this.isExpireFilter,
        this.sele.areaId,
        this.sele.shelfId,
        this.sele.location,
        this.filetype == 0 ? undefined : this.filetype,
        this.stage == 0 ? undefined : this.stage,
        this.security == 0 ? undefined : this.security,
        this.startFilterDate ? moment(this.startFilterDate) : null,
        this.endFilterDate ? moment(this.endFilterDate) : null,
        includeState,
        exceptState,
        this.filterText,
        sorting,
        maxResultCount,
        skipCount
      )
        .subscribe((result) => {
          reject(result);
        });
    })
  }

  lendfile(id: string): void {

    this.boor.ids = new Array<string>(id);
    this.boor.state = TechFileState.借出;
    this.boor.ation = AtionState.借出;
    this._techFileOutServiceProxy.affirmTechFile(
      this.boor
    ).subscribe((result) => {

      this.reloadPage();
    });

  }

  retunfile(id: string): void {
    this.boor.ids = new Array<string>(id);
    this.boor.state = TechFileState.正常;
    this.boor.ation = AtionState.归还;
    this._techFileOutServiceProxy.affirmTechFile(
      this.boor
    ).subscribe((result) => {

      this.reloadPage();
    });

  }

  refusaltoreturn(id: string): void {
    this.boor.ids = new Array<string>(id);
    this.boor.state = TechFileState.借出; //拒绝归还的上一个状态为借出或待归还
    this.boor.ation = AtionState.归还;
    this._techFileOutServiceProxy.refuseTechFile(
      this.boor
    ).subscribe((result) => {

      this.reloadPage();
    });

  }

  refusaltolend(id: string): void {
    this.boor.ids = new Array<string>(id);
    this.boor.state = TechFileState.正常; //拒绝借出的上一个状态为正常
    this.boor.ation = AtionState.借出;
    this._techFileOutServiceProxy.refuseTechFile(
      this.boor
    ).subscribe((result) => {

      this.reloadPage();
    });

  }

  SelectedTechfilegh() {
    let selectedidsgh = new Array<string>();
    for (let index = 0; index < this.selectedProductsgh.length; index++) {
      selectedidsgh.push(this.selectedProductsgh[index].id);
    }
    let boorgh = new BorrowTechFileDto();
    boorgh.ids = selectedidsgh;
    boorgh.state = TechFileState.正常;
    boorgh.ation = AtionState.归还;
    this._techFileOutServiceProxy.affirmTechFileAll(
      boorgh
    ).subscribe((result) => {

      this.reloadPage();
    });
  }

  SelectedTechfilejjgh() {
    let selectedidsgh = new Array<string>();
    for (let index = 0; index < this.selectedProductsgh.length; index++) {
      selectedidsgh.push(this.selectedProductsgh[index].id);
    }
    let boorgh = new BorrowTechFileDto();
    boorgh.ids = selectedidsgh;
    boorgh.state = TechFileState.借出; //拒绝归还的上一个状态为借出或待归还
    boorgh.ation = AtionState.归还;
    this._techFileOutServiceProxy.refuseTechFileAll(
      boorgh
    ).subscribe((result) => {

      this.reloadPage();
    });
  }



  SelectedTechfilejc() {
    let selectedidsjc = new Array<string>();
    for (let index = 0; index < this.selectedProductsjc.length; index++) {
      selectedidsjc.push(this.selectedProductsjc[index].id);
    }
    let boorjc = new BorrowTechFileDto();
    boorjc.ids = selectedidsjc;
    boorjc.state = TechFileState.借出;
    boorjc.ation = AtionState.借出;
    this._techFileOutServiceProxy.affirmTechFileAll(
      boorjc
    ).subscribe((result) => {

      this.reloadPage();
    });
  }


  SelectedTechfilejjjc() {
    let selectedidsjc = new Array<string>();
    for (let index = 0; index < this.selectedProductsjc.length; index++) {
      selectedidsjc.push(this.selectedProductsjc[index].id);
    }
    let boorjc = new BorrowTechFileDto();
    boorjc.ids = selectedidsjc;
    boorjc.state = TechFileState.正常; //拒绝借出的上一个状态为正常
    boorjc.ation = AtionState.借出;
    this._techFileOutServiceProxy.refuseTechFileAll(
      boorjc
    ).subscribe((result) => {

      this.reloadPage();
    });
  }

  SelectedTechfileVoid() {
    let selectedidsvoid = new Array<string>();
    for (let index = 0; index < this.selectedProductsupdate.length; index++) {

      if (this.selectedProductsupdate[index].status != TechFileState.正常) {
        this.message.warn("只能作废正常状态的文件！", "作废失败！");
        return;
      }
      selectedidsvoid.push(this.selectedProductsupdate[index].id);
    }

    let input = new TechFileBaseInputDto();
    input.ids = selectedidsvoid;
    input.positionId = this.positionId;
    input.remarks = "";
    this._techFileIntoServiceProxy.voidTechFile(
      input
    ).subscribe((result) => {

      this.reloadPage();
    });
  }

  SelectedTechfileVoidBack() {
    let selectedidsvoidback = new Array<string>();
    for (let index = 0; index < this.selectedProductsvoided.length; index++) {
      selectedidsvoidback.push(this.selectedProductsvoided[index].id);
    }

    let input = new TechFileBaseInputDto();
    input.ids = selectedidsvoidback;
    input.positionId = this.positionId;
    input.remarks = "";
    this._techFileIntoServiceProxy.voidTechFileBack(
      input
    ).subscribe((result) => {

      this.reloadPage();
    });
  }

  reloadPage(): void {
    this.getTabsMaxCount();
    this.getTabsProduction(this.tabIndex)
    // this.paginatorNormal.changePage(this.paginatorNormal.getPage());
    // this.paginatorSpecial.changePage(this.paginatorSpecial.getPage());
    // this.paginatorTobe.changePage(this.paginatorTobe.getPage());
    // this.paginatorOnloan.changePage(this.paginatorOnloan.getPage());
    // this.paginatorReturning.changePage(this.paginatorReturning.getPage());
    // this.paginatorBoorwte.changePage(this.paginatorBoorwte.getPage());
    // this.paginatorVoid.changePage(this.paginatorVoid.getPage());
    // this.paginatorVoided.changePage(this.paginatorVoided.getPage());
    this.selectedProducts = [];
    this.selectedProductsgh = [];
    this.selectedProductsjc = [];
    this.selectedProductsupdate = []; 
    this.selectedProductsvoided = [];

  }


  // deleteProduction(production: ProductionOutput): void {
  //   this.message.confirm(
  //     '删除【' + production.id + '】,图号：' + production.picNo + '的零件定额',
  //     this.l('AreYouSure'),
  //     (isConfirmed) => {
  //       if (isConfirmed) {
  //         this._libraryOfLaborServiceProxy.deleteProduction(production.id)
  //           .subscribe(() => {
  //             this.reloadPage();
  //             this.notify.success(this.l('SuccessfullyDeleted'));
  //           });
  //       }
  //     }
  //   );
  // }


  //接收
  putSelectedTechfile() {//ReceivePutTechFile
    this.selectedids = new Array<string>();
    for (let index = 0; index < this.selectedProducts.length; index++) {
      if (!this.selectedProducts[index].isiteffective) {
        this.message.warn("文件[" + this.selectedProducts[index].fileName + "]历史版本未追回或未接收！", "接收失败！");
        return;
      }
      this.selectedids.push(this.selectedProducts[index].id);

    }
    this.putAllIntoModal.show(this.selectedids, false);
  }

  //批量修改
  UpdateSelectedTechfile() {
    let selectedidsupdate = new Array<string>();
    for (let index = 0; index < this.selectedProductsupdate.length; index++) {
      selectedidsupdate.push(this.selectedProductsupdate[index].id);
    }
    this.putAllIntoModal.show(selectedidsupdate, true);
  }

  uploadExcel(data: { files: File }): void {
    this.primengTableHelperNormalProductions.showLoadingIndicator();

    const formData: FormData = new FormData();
    const file = data.files[0];
    formData.append('file', file, file.name);
    this._httpClient
      .post<any>(this.uploadUrl, formData)
      .pipe(finalize(() => this.excelFileUpload.clear()))
      .subscribe(response => {
        this.primengTableHelperNormalProductions.hideLoadingIndicator();

        if (response.success) {
          this.message.success('导入Excel成功');

          //this.importSalaryDtoList.salaryList = this.salary;
        } else if (response.error != null) {
          this.message.error('导入Excel失败');
        }

      });
  }

  onUploadExcelError(): void {
    this.primengTableHelperNormalProductions.hideLoadingIndicator();
    this.notify.error('上传失败');
  }

  showPositionDialog(id: string, event?: LazyLoadEvent) {
    this.displayBasic = true;
    this.getFileRecord(id, event);
    setTimeout(() => {
        $('p-dialog > .ui-dialog').css({'top': '16%'});
    }, 100);
  }

}